package com.dubbo.consumer.regController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dubbo.common.dtos.ResponseResult;
import com.dubbo.model.balance.dtos.PageRequestDto;
import com.dubbo.model.regulate.dtos.RegProductDto;
import com.dubbo.model.regulate.pojos.RegProduct;
import com.dubbo.regulate.CatalogService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/*
* 服务目录
* */
@RestController
@RequestMapping("/catalog")
public class CatalogController {

    @Reference(check = false)
    private CatalogService catalogService;

    /**
     * 页面展示
     * @return
     */
    @GetMapping("/ParentsCatalogList")
    ResponseResult<List<RegProduct>> ParentsCatalogList(PageRequestDto dto){

        return catalogService.ParentsCatalogList(dto);
    }

    /*
    上下架
    * */
    @GetMapping("/SoldOutUp")
    public ResponseResult SoldOutUp(@RequestBody Map<String,Object> Sold){
        Integer id = (Integer) Sold.get("id");
        String pType = (String) Sold.get("pType");

        RegProductDto dto = new RegProductDto();
        dto.setId(id);
        dto.setPState(pType);
        return catalogService.SoldOutUp(dto);
    }

}
